<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<!DOCTYPE html>
<html>
<head>
    <title>按地区汇总</title>
	<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
                            
    <section class="content-header">
        <h1>区域采购计划查看</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="#">采购计划管理</a></li>
            <li class="active"><a href="#">区域采购计划查看</a></li>
        </ol>
    </section>
    
    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
            	<div class="input">
            		<div class="textalign1">地区：</div>
            		<div class="boxinput">
            			<table style="width:100%;">
            				<tr>
            					<td style="width:33%;">
            						<select class="textinput" id="area1" name="area1" disabled="disabled">
			                        	<option value="${area.areaId }">${area.areaName }</option>
			                        </select>
            					</td>
            					<td style="width:33%;">
            						 <select class="textinput"  id="area2" name="area2"></select>
            					</td>
            					<td style="width:33%;">
            						 <select class="textinput"  id="area3" name="area3"></select>
            					</td>
            				</tr>
            			</table>
            		</div>
            		<div class="textalign">
            			<button type="button" class="btn btn-success btn-sm" onclick="search();" id="selectc">查询</button>
            		</div>
            	</div>
            </div>
        </div>
        
        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
        
        <div class=" box box-warning bottongroup">
             <a href="${ctx }/wsjplan/toWsjProjectList.html" class="btn btn-default btn-sm" >返&nbsp;回</a>
        </div>
    </section>
    <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">
		
    //绑定回车
    $('#area1,#area2,#area3').bind('keydown', function(event) {
        if (event.keyCode == "13") {        //13 位电脑上回车键的位置代码
            $('#selectc').click();
        }
    }); 
		
    $("#area2").focus();//加载页面光标在第一个查询框内
    
        function search(page) {
            
        	var area2 = $.trim($("#area2").val());
    		var area3 = $.trim($("#area3").val());
            $("#gridlist").jqGrid('setGridParam',{  
                datatype:'json',
                postData:{
                	  "area2":area2,
	        		  "area3":area3},
                page : (page || 1)
            }).trigger("reloadGrid"); //重新载入  
        }
    
        $(function () {
            $("#gridlist").jqGrid({
                url: "getWsjPlanByAreaList.html",
                mtype: "post",
                datatype: "json",
                postData: {"projId" : "${projId}"},
                autowidth: true,
                height: 270,
                colNames: [
                    '地区编码', 
                    '地区名称',
                    '地区全称',
                    '状态', 
                    '已申报药品数量',
                ],
                colModel: [
                    { name: 'areaId', width: 10, align:"center", sortable: false},
                    { name: 'areaName', width: 15, align:"center", sortable: false },
                    { name: 'arFullname', width: 10, align:"center", sortable: false},
                    { name: 'status', width: 10, align:"center", sortable: false,
                    	formatter: function (val,opts,row){
                    		if(row.status == 1){
                    			return "启用";
                    		}else if(row.status == 0){
                    			return "停用";
                    		}else{
                    			return "";
                    		}
                    	}	
                    },
                    { name: 'drugCount', width: 10, align:"center", sortable: false,
                        formatter: function (val, opts, rowdata) {
                        	
                            return "<a href="+encodeURI(encodeURI("toWsjPlanDetailsByArea.html?projId=${projId}&areaName="+rowdata.areaName+"&projName=${projName}&areaId=" + rowdata.areaId))+">"+val+"</a>";
                        }   	
                    }
                ], 
                rowNum: 20,
                rowList: [10, 20, 50, 100],
                rownumbers: true,
                pager: "#gridpage",
                viewrecords: true,
                caption: "${projName} - 按地区汇总",
                jsonReader: {
                   
                },
                gridComplete:function(){
                    //序号列宽度自适应（参数为jqgridID）
                    autoRNWidth("gridlist");
                    //数据只有一条时默认选中（参数为jqgridID）
                    selectByOneData("gridlist");
                }
            });
            
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            
            $("#area2").HNSelect({
            	parent_selector: "#area1",  url: "${pageContext.request.contextPath}/selectController/getArea.html", dataid: "ID",defaultText: "<option value=''>请选择</option>",
                func: function () {
                    $("#area3").HNSelect({
                        parent_selector: "#area2", url: "${pageContext.request.contextPath}/selectController/getArea.html", dataid: "ID", defaultText: "<option value=''>请选择</option>",
                    });
                }
            });
            $(window).trigger("resize");
            
        });
    </script>
</body>
</html>